package com.ermace.robo.jumper.game.Player;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;

import com.ermace.robo.jumper.R;
import com.ermace.robo.jumper.game.GameView;

public enum RobotColour {
	RED(R.drawable.spritesheet_red, Color.RED),
	BLUE(R.drawable.spritesheet_blue, Color.BLUE),
	GREEN(R.drawable.spritesheet_green, Color.GREEN),
	PURPLE(R.drawable.spritesheet_purple, Color.MAGENTA),
	YELLOW(R.drawable.spritesheet_yellow, Color.YELLOW),
	ORANGE(R.drawable.spritesheet_orange, Color.rgb(255, 144, 0)),
	NONE(-1, Color.WHITE);
	
	private int spriteSheet;
	private int color;
	private Bitmap bmp = null;

	public static RobotColour getByOrdinal(int ordinal) {
		int amount = RobotColour.values().length;
		return RobotColour.values()[ ((ordinal % amount) + amount) % amount];
	}
	
	private RobotColour(int spriteSheetId, int color) {
		this.spriteSheet = spriteSheetId;
		this.color = color;
	}
	
	public Bitmap getSpriteSheet() {
		if (bmp == null && spriteSheet != -1)
			bmp = BitmapFactory.decodeResource(GameView.resources, spriteSheet);
		
		return bmp;
//		return Bitmaps.getInstance().getBitmap(spriteSheet);
	}
	
	public Bitmap getSpriteSheet(Resources res) {
		if (bmp == null && spriteSheet != -1)
			bmp = BitmapFactory.decodeResource(res, spriteSheet);
		
		return bmp;
//		return Bitmaps.getInstance().getBitmap(spriteSheet);
	}
	
	public int getColor() {
		return color;
	}
}
